import { hasPermissionOfPoint } from '@/utils/permission'

export default {
  methods: {
    // 检查权限函数
    hasPermission (point) {
      return hasPermissionOfPoint(point)
    },
    // 学科模块，目录或标签状态为0:禁用时，才可以修改
    checkAble (state) {
      const ableMap = {
        0: false,
        1: true
      }
      return ableMap[state]
    }
  },
  directives: {
    // 自定义检查权限点指令
    permission: {
      inserted: function (el, binding) {
        const point = binding.value
        if (!hasPermissionOfPoint(point)) {
          el.style.display = 'none'
        }
      }
    }
  }
}
